#ifndef __AS_STD_LIB__H__
#define __AS_STD_LIB__H__

#include "ASDataType.h"


#if defined(AS_RUN_ON_MRE)
#define as_sprintf sprintf
#define as_strcat strcat
#define as_strncpy strncpy
#elif defined(AS_RUN_ON_SKY)
#define as_sprintf mrc_sprintf
#define as_strcat mrc_strcat
#define as_strncpy mrc_strncpy
#endif
/*std lib functions*/
ASVOID* as_memset(ASVOID *dst, ASINT ch, ASUINT size);
ASVOID* as_memcpy(ASVOID *dst, ASVOID *src, ASUINT count);
ASINT as_strlen(ASSTR str);
ASINT as_strcmp(const ASSTR s1, const ASSTR s2);
ASSTR as_strcpy(ASSTR dest, ASSTR src);
ASINT as_atoi(ASSTR str);

ASINT as_wstrlen(ASWSTR wstr);
ASVOID as_wstrcpy(ASWSTR dst_wstr, const ASWSTR src_wstr);
ASVOID as_wstrncpy(ASWSTR dst_wstr, const ASWSTR src_wstr, ASINT cnts);
ASVOID as_wstrcat(ASWSTR dst_wstr, ASWSTR cat_wstr);
ASINT as_wstrcmp(ASWSTR dst_wstr, ASWSTR src_wstr);

/*memory functions*/
ASVOID* as_calloc(ASINT size);
ASVOID* as_malloc(ASINT size);
ASVOID* as_realloc(ASVOID* ptr, ASINT size);
ASVOID as_free(ASVOID* ptr);

/*file functions*/
ASINT as_file_open(ASSTR gb_path, as_file_op_mode mode);
ASVOID as_file_read(ASINT fh, ASVOID* data_p, ASINT len, ASINT* read);
ASVOID as_file_write(ASINT fh, ASVOID* data_p, ASINT len, ASINT* write);
ASINT as_file_seek(ASINT fh, ASINT offset, as_file_seek_type seek_type);
ASVOID as_file_delete(ASSTR gb_path);
ASVOID as_file_rename(ASSTR dst_gb_path, ASSTR src_gb_path);
ASVOID as_file_close(ASINT fh);
as_ret as_filedir_create(ASSTR gb_path);
as_ret as_filedir_delete(ASSTR gb_path);
ASINT as_inter_file_get_filesize(ASSTR gb_name);
//out_buffer should be ASNULL,if success,function will use this ptr to alloc memory and save info
ASVOID as_inter_file_load_data(ASSTR gb_name, ASUINT8** out_buffer, ASINT* out_len);
ASVOID as_inter_file_load_data_patial(ASSTR gb_name, ASUINT8** out_buffer, ASINT* out_len,
                                      ASINT offset_from_begin, ASINT len_want_read);

/*chars set functions*/
ASWSTR as_ucs2_from_gb2312(ASSTR gb_str);
ASWSTR as_ufg_tmp(ASINT idx, ASSTR gbs);
ASWSTR as_ucs2_from_ascii(ASSTR astr);
ASSTR as_ascii_from_ucs2(ASWSTR ucs2_str);

ASINT as_ucs2_to_ascii(ASSTR dst, ASWSTR src);
ASINT as_ascii_to_ucs2(ASWSTR dst, ASSTR src);

/*time function*/
/*followings: month or day begin with 1.
 *week idx: 0~6(Sunday ~ Saturday)
 */
ASVOID as_get_time(as_time* time_p);
ASBOOL as_get_if_leap_year(ASUINT16 year);
ASUINT8 as_get_days_of_month(ASUINT16 year, ASUINT8 month);
ASUINT16 as_get_day_of_year(ASUINT16 year, ASUINT8 month, ASUINT8 day);
ASUINT8 as_get_week(ASUINT16 year, ASUINT8 month, ASUINT8 day);
ASUINT8 as_get_week_of_year(ASUINT16 year, ASUINT8 month, ASUINT8 day);
ASBOOL as_get_if_same_week(as_time time1, as_time time2);
ASINT32 as_get_days(as_time time1, as_time time2);
#endif//__AS_STD_LIB__H__